%Trains two layer feed forward network with momentum 
%latest date 05:01:2003

clear;

load e:\manoj\data\spike.dat;
load e:\manoj\data\dummy.dat;

len   = 24;
st    = 1;
en    = 24;


SPK = [spike' dummy']';
P  = SPK(:,1:20); 

T  = SPK(:,21);

P  = P';
T  = T'/20;
[R Q] = size(P);
[S2 Q] = size(T); 


S1 	    = 3; %hidden layer
disp_freq = 100;			
mom_cnst  = 0.2; %momentem constant
lr 	    = 0.021; % learning rate
max_epoch = 1000;
err_goal  = 10^(-4);
max_err   = 1.04;
tf = ['tansig';'tansig'];

[W10,B10] =  rands(S1,R);

W20 = rands(S2,S1)*0.5;
B20 = rands(S2,1)*0.5;


TP = [disp_freq max_epoch err_goal lr mom_cnst max_err];
[W1,B1,W2,B2,epoch,errors] = trainbpm(W10,B10,tf(1,:),W20,B20,tf(2,:),P,T,TP);

st1   = 1;
en1   = 50;
K=dummy(:,1:20);
a1 = simuff(K',W1,B1,tf(1,:),W2,B2,tf(2,:));
sse = sum((a1*20-dummy(:,21)').^2)





 